#ifndef UIMANAGER_H
#define UIMANAGER_H

#include <QObject>
#include <QString>
#include <thread>

//全局单例

class UiManager : public QObject
{
    Q_OBJECT
public:
    static UiManager* getInstance();

/*********************暴露给UiSyncService类的接口**************************/
public:


/*********************暴露给QML的接口和属性**************************/

//qml可以调用的方法
public:
    Q_INVOKABLE int start();
    Q_INVOKABLE int serviceStart();
    Q_INVOKABLE int openCanDebugPort();
    Q_INVOKABLE int refreshUi();

//可由qml访问的属性
//public下，Q_PROPERTY(类型 qml中引用名 READ 读取函数 NOTIFY 信号函数)
public:
    //窗口标题名
    Q_PROPERTY(QString titleName READ getTitleName() NOTIFY titleNameChanged)
    QString getTitleName();
    //连接状态标志
    Q_PROPERTY(QString connectStateLabel READ getConnectStateLabel NOTIFY connectStateLabelChanged)
    QString getConnectStateLabel();
    //串口接收字符串
    Q_PROPERTY(QString serialRecieve READ getSerialRecieve NOTIFY serialRecieveChanged )
    QString getSerialRecieve();

signals:
    void titleNameChanged();
    void connectStateLabelChanged();
    void serialRecieveChanged();

/*********************私有上下文**************************/
private:
    static UiManager    _uiManager;     //全局单例
    UiManager();
    ~UiManager();

    QString windowsTitle;       //窗口标题名
    QString versionString;      //版本字符串
    QString connectStateLabel;  //连接状态标签
    QString serialRecieve;       //串口接收缓存
    std::thread* _thread;        //后台线程
    void _backendThreadFunc(void);

signals:

};

#endif // UIMANAGER_H
